package com.mrjy.queries.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.QuestionNoticeInfo;
import com.mrjy.common.entity.UserInfo;
import com.mrjy.common.util.GlobalConstant;
import com.mrjy.queries.bo.IQuestionNoticeBo;

@RequestMapping("/queries/questionNotice")
@Controller
public class QuestionNoticeController {
	
	@Resource
	private IQuestionNoticeBo noticeBo;

	/**
	 * 统计未读通知消息总数
	 * @param session
	 * @return
	 */
	@RequestMapping("/countNotice")
	@ResponseBody
	public int countNotice(HttpSession session){
		UserInfo userInfo = ((UserInfo) session.getAttribute(GlobalConstant.USER_INFO));
		return noticeBo.countNoRead(userInfo);
	}
	
	/**
	 * 获取未读通知
	 * @param session
	 * @return
	 */
	@RequestMapping("/getUnreadNotice")
	@ResponseBody
	public Object getUnreadNotice(QuestionNoticeInfo notice, HttpSession session){
		UserInfo userInfo = ((UserInfo) session.getAttribute(GlobalConstant.USER_INFO));
		return noticeBo.queryNoReadNotice(notice, userInfo);
	}
	
	/**
	 * 获取已读历史通知
	 * @param session
	 * @return
	 */
	@RequestMapping("/readHistoryNotice")
	@ResponseBody
	public Object readHistoryNotice(QuestionNoticeInfo notice, HttpSession session){
		UserInfo userInfo = ((UserInfo) session.getAttribute(GlobalConstant.USER_INFO));
		return noticeBo.queryNotice(notice,userInfo);
	}
	
}
